﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;

namespace Smash
{
    class Program
    {
        public static IPAddress MyIP
        {
            get
            {
                return System.Net.Dns.GetHostEntry(
                         System.Net.Dns.GetHostName())
                       .AddressList[0];
            }
        }

        public static IPHostEntry HostEntry
        {
            get
            {
                return System.Net.Dns.GetHostEntry(
                         System.Net.Dns.GetHostName());
            }
        }

        static void Main(string[] args)
        {
            Console.Title = "Smash! Fake Video Server";
            foreach (IPAddress addr in HostEntry.AddressList)
            {
                if (addr.AddressFamily == AddressFamily.InterNetwork)
                {
                    FakeVideoServer server = new FakeVideoServer(addr, 1234);
                    Thread.Sleep(75);

                    if (server.Running)
                    {
                        Console.Title = "Smash! Fake Video Server : "
                                          + addr.ToString();
                        Console.WriteLine("started server on " + addr);
                        break;
                    }
                    else
                    {
                        Console.WriteLine("failed to start server on " + addr);
                    }
                }
            }
        }
    }
}
